using System;
using L=Science.Physics.GeneralPhysics;

namespace Serway.Chapter17
{
	/// <summary>
	/// Example01: Speed of Sound in a Liquid
	/// (A) Find the speed of sound in water, which has a bulk
	/// modulus of 2.1 \times 10^9 N/m^2 at a temperature 
	/// of 0^{\circle} C and a density of 1.0 \times 10^3 kg/m^3.
	/// v_{water} = 1.4 km/s
	/// (B) Dolphins use sound waves to locate food. Experiments have
	/// shown that a dolphin can detect a 7.5 cm target 110 m away,
	/// even in murky water. For a bit of dinner at that distance, how
	/// much time passes between the moment the dolphin emits a sound
	/// pulse and the moment the dolphin hears its reflection and
	/// thereby detects the distant target?
	/// \Delta t = 0.14 s
	/// </summary>
	public class Example01
	{
		public Example01()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
		public void Compute()
		{
			L.Elasticity we = new L.Elasticity();
			L.Density wr = new L.Density();
			we.BulkModulus = 2.1E9;
			wr.kgPERmCUBE = 1.0E3;
			L.Sound s = new L.Sound();
			//(A)
			double speed = s.Speed(we,wr);
		    result+=Convert.ToString(speed)+"\r\n";
			//(B)
			double dis = 110.0*2.0;
			result+=Convert.ToString(dis/speed);
		}
	}
}
